﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once     
#include <vector>
#include "OwnerPtr.h"
#include "IFamilySketch.h"
#include "GmFamilyService.h"
#include "ElementId.h"

namespace gcmp 
{
    class IPolygon;
}

namespace gfam
{ 
    class IFamilySketchPlane;
    class IFamilySketchCurve;
    enum class FamilySketchState;

    /// \brief 二维草图的接口类
    class GM_FAMILY_SERVICE_EXPORT IFamilySketch2D : public IFamilySketch
    {
        DEFINE_CAST_DERIVED(gfam::IFamilySketch2D, gfam::IFamilySketch)
    public:
        /// \brief 析构函数
        virtual ~IFamilySketch2D() {};

        /// \brief 创建一个二维草图对象
        /// 
        /// \param pDoc          所属文档
        /// \param sketchPlaneId 参照平面的Id
        /// \return 若创建成功则返回IFamilySketch2D*，否则返回nullptr
        static IFamilySketch2D* Create(gcmp::IDocument* pDoc, const gcmp::ElementId& sketchPlaneId);

        /// \brief 获取草图上的所有二维轮廓曲线，不包括轴线，定位线等
        /// 
        /// \param curves 用来保存返回结果的数组
        /// \return 无
        virtual void GetAll2DCurvesNormal(std::vector<IFamilySketchCurve*>& curves) const = 0;

        /// \brief 获取草图上的多边形（不返回错误信息）
        /// 
        /// \param polygonlist 用来保存返回结果的数组
        /// \return EnSketchState状态
        virtual FamilySketchState GetPolygons(std::vector<gcmp::OwnerPtr<gcmp::IPolygon> >& polygonlist) const = 0;

        /// \brief 获取草图上的多边形（返回错误信息）
        /// 
        /// \param polygonlist 用来保存返回结果的数组
        /// \param errorCurves 存放错误信息的数组
        /// \return EnSketchState状态
        virtual FamilySketchState GetPolygonsAndGetErrorCurves(std::vector<gcmp::OwnerPtr<gcmp::IPolygon> >& polygonlist, std::vector<IFamilySketchCurve*>& errorCurves) const = 0;

        /// \brief 获取草图平面的ElementId
        /// 
        /// \return 草图平面的ElementId
        virtual gcmp::ElementId GetSketchPlaneId() const = 0;

        /// \brief 获取草图上的轴线，轴线唯一时返回才不为空
        /// 
        /// \return 当轴线唯一时，返回const IFamilySketchCurve*，否则返回nullptr
        virtual const IFamilySketchCurve* GetAxisLine() const = 0;

        /// \brief 获取草图平面的指针
        /// 
        /// \return 返回草图平面的指针（FamSketchPlane*）
        virtual IFamilySketchPlane* GetSketchPlaneFW() = 0;

        /// \brief 获取草图平面的指针
        /// 
        /// \return 返回草图平面的指针（const FamSketchPlane*）
        virtual const IFamilySketchPlane* GetSketchPlane()const = 0;

        /// \brief 根据名称获取定位线
        /// 
        /// \ name 名称
        /// \return 定位线指针
        virtual const IFamilySketchCurve* GetLocationLineByName(const std::wstring& name) const = 0;

    };
}